package com.wutong.common_server.result;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import springfox.documentation.annotations.ApiIgnore;

import java.io.Serializable;
import java.util.List;


@ApiIgnore
@Setter
@Getter
@NoArgsConstructor
public class DataTablePageDto<T> implements Serializable {

	private static final long serialVersionUID = -8573855566812280377L;

	@ApiModelProperty(hidden = true )
	@TableField(exist = false)
	//@JsonInclude(JsonInclude.Include.NON_NULL) //属性为空时不序列化
	private List<T> rows;         //包含的数据

	@ApiModelProperty(hidden = true )
	@TableField(exist = false)
	private Long total;//总长度

	@ApiModelProperty(hidden = true )
	@TableField(exist = false)
	private Integer pageIndex;    //第几条数据开始查询

	@ApiModelProperty(hidden = true )
	@TableField(exist = false)
	private Integer pageSize;    //每页显示几条

	public DataTablePageDto(Page<T> list) {
		if (list.getSize() > 0) {
			this.rows = list.getRecords();
			this.total = list.getTotal();
		}
	}

}
